<p>This rule raises an issue when code creates a new Date object just to get the current timestamp as a number.</p>
<h2>Why is this an issue?</h2>
<p>Creating a <code>Date</code> object and then immediately converting it to a number is unnecessarily verbose and inefficient. JavaScript provides
<code>Date.now()</code> as a direct way to get the current timestamp.</p>
<p>When you write <code>new Date().getTime()</code> or similar patterns, you are:</p>
<ul>
  <li> Creating an unnecessary object instance </li>
  <li> Using more memory than needed </li>
  <li> Writing more code than necessary </li>
  <li> Making the intent less clear </li>
</ul>
<p>The <code>Date.now()</code> method was specifically designed for this purpose. It returns the number of milliseconds since January 1, 1970 UTC,
which is exactly what these other patterns achieve but in a more direct way.</p>
<p>Patterns like <code>+new Date()</code> or <code>Number(new Date())</code> rely on JavaScript’s type coercion, which can be confusing for other
developers reading the code. These implicit conversions make the code harder to understand at first glance.</p>
<h3>What is the potential impact?</h3>
<p>This issue affects code readability and performance. While the performance impact is minimal in most cases, using <code>Date.now()</code> is the
standard, recommended approach that clearly expresses the intent to get the current timestamp.</p>
<h3>How to fix?</h3>
<p>Replace <code>new Date().getTime()</code> with <code>Date.now()</code> to get the current timestamp more efficiently.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const timestamp = new Date().getTime(); // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const timestamp = Date.now();
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-date-now.md">prefer-date-now</a> </li>
  <li> MDN: Date.now() - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now">Official documentation
  for the Date.now() method</a> </li>
  <li> MDN: Date.prototype.getTime() - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime">Documentation for the getTime() method on Date
  instances</a> </li>
</ul>
